package o;

import android.net.Uri;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;

public final class cej {
    public static Set<String> ˎ(String str) {
        if (str == null) {
            return Collections.emptySet();
        }
        Set linkedHashSet = new LinkedHashSet();
        int i = 0;
        while (true) {
            try {
                int indexOf = str.indexOf(38, i);
                if (indexOf == -1) {
                    indexOf = str.length();
                }
                int indexOf2 = str.indexOf(61, i);
                if (indexOf2 > indexOf || indexOf2 == -1) {
                    indexOf2 = indexOf;
                }
                linkedHashSet.add(Uri.decode(str.substring(i, indexOf2)));
                indexOf2 = indexOf + 1;
                if (indexOf2 >= str.length()) {
                    break;
                }
                i = indexOf2;
            } catch (Exception e) {
                Logger.ˋ("UriUtil", "getQueryParameterNames error");
            }
        }
        return Collections.unmodifiableSet(linkedHashSet);
    }

    public static String ˊ(String str, String str2) {
        if (str == null || str2 == null) {
            return null;
        }
        return ˊ(Uri.parse(str), str2);
    }

    public static String ˊ(Uri uri, String str) {
        String str2 = null;
        if (ˎ(uri.getEncodedQuery()).contains(str)) {
            try {
                str2 = uri.getQueryParameter(str);
            } catch (Exception e) {
                Logger.e("UriUtil", "getParameterValue error," + e.toString());
            }
        }
        return str2;
    }
}
